home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS11.ADF
/
C
/
DirUtil
/
pwd.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-08-05
|
2KB
|
102 lines
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/lists.h>
#include <exec/ports.h>
#include <exec/devices.h>
#include <exec/exec.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <graphics/gfxbase.h>
#include <graphics/gfx.h>
#include <graphics/text.h>
#include <graphics/regions.h>
#include <graphics/copper.h>
#include <graphics/gels.h>
#include <graphics/clip.h>
#include <graphics/view.h>
#include <graphics/rastport.h>
#include <graphics/layers.h>
#include <devices/serial.h>
#include <devices/keymap.h>
#include <hardware/blit.h>
#include <stdio.h>
#include <ctype.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
extern APTR AllocMem();
unsigned int mask = 0;
#define INTUITION 0x00000001
#define GRAPHICS 0x00000002
#define SCREEN 0x00000004
#define WINDOW 0x00000008
#define COLORMAP 0x00000010
#define MATH 0x00000020
#define MATHTRANS 0x00000040
#define FBSIZE (sizeof (struct FileInfoBlock))
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct IntuiMessage *message;
struct RastPort *rp;
struct Window *w;
#define MAXFNAME 15
#define MAXCHAR 30
char *pwd()
{
struct FileLock *fl1;
struct FileLock *fl2;
struct FileInfoBlock *fb;
static char dir[300];
char tmpdir[300];
*dir = 0;
*tmpdir = 0;
/* Mallocate memory for the file info block */
fb = AllocMem(FBSIZE,MEMF_CLEAR | MEMF_PUBLIC);
fl2 = Lock(":",ACCESS_READ);
fl1 = CurrentDir(fl2);
CurrentDir(fl1);
/* If the root directory is not the main lock then close it */
if (fl2 != NULL)
UnLock(fl2);
for (;;)
{
if (!Examine(fl1,fb))
{
FreeMem(fb,FBSIZE);
close_things();
exit();
}
/* Get the parent lock if there is one */
fl2 = ParentDir(fl1);
/* If this is the end then break out of the loop */
if (!fl2)
break;
sprintf(dir,"/%s%s",fb->fib_FileName,tmpdir);
strcpy(tmpdir,dir);
fl1 = fl2;
}
*dir = ':';
FreeMem(fb,FBSIZE);
return (dir);
}